<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		*{
			margin: 0px;
			padding: 0px;
			list-style: none;
		}
		html,body{
			height: 100%;
		}
		.bg{
			width: 100%;
			height: 100%;
			background: rgba(0,0,0,0.5) url() 0 0 no-repeat;
			position: fixed;
			top: 0px;
			left: 0px;
			display: none;
		}
		.out{
			width: 500px;
			height: 300px;
			background: #fff url() 0 0 no-repeat;
			position: fixed;
			top: -300px;
			left: 50%;
			margin-left: -250px;
		}


	</style>
	<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$('#btn').click(function(event) {
				$('.bg').fadeIn();
				$('.out').animate({top:'200px'},200);
			});

			$('.bg').click(function(event) {
				$('.bg').fadeOut();
				$('.out').animate({top:'-300px'},200);
			});
		})
	</script>
</head>
<body>
	<button id="btn">注册</button>
	<div class="bg"></div>
	<div class="out">我是弹出层</div>
</body>
</html>